Skip to content

Fix ASGI SIGTERM handler to chain to host server and skip lifespan scope - #240

Closed
sharosoo wants to merge 1 commit into
restatedev:mainfrom
sharosoo:fix/restate-sdk-python-sigterm-fix
Closed

sharosoo wants to merge 1 commit into
restatedev:mainfrom
sharosoo:fix/restate-sdk-python-sigterm-fix

Conversation

@sharosoo

Copy link
Copy Markdown

Fixes #236.

Changes

  • Reject lifespan and non-http scopes before installing the SIGTERM handler so lifespan probes do not displace the host server's signal handler.
  • Capture the existing SIGTERM handler from both getattr(loop, '_signal_handlers', {}).get(signal.SIGTERM) (used by loop.add_signal_handler hosts such as Hypercorn) and signal.getsignal(signal.SIGTERM) (used by signal.signal hosts such as Uvicorn) before registering _on_sigterm.
  • Chain to the captured handler from _on_sigterm after notifying active ReceiveChannel instances.
  • Add unit tests in tests/server.py covering loop.add_signal_handler chaining (including callback arguments), signal.signal chaining, and lifespan / non-http scopes.

Related: #226.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sharosoo

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@igalshilman

Copy link
Copy Markdown
Contributor

thank you for your contribution and reporting this, it should be solved in the latest released version already.
let me know if this works/doesn't work for you and I will close it.

@igalshilman igalshilman closed this Nov 5, 2026
@igalshilman igalshilman reopened this Nov 5, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
@igalshilman igalshilman closed this Nov 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASGI app SIGTERM handler silently replaces the hosting server's handler

2 participants